package Meituan;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.google.common.collect.Sets;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 50:0.1,100:0.1,150:0.3,200:0.5
 * 50:0.2,100:0.5,150:0.2,200:0.1
 * 测试Sets.difference是否返回null
 * @author: leiwenkang02@meituan.com
 * @date: 2018/4/19
 * @time: 20:31
 */
public class Test01 {
    public static void main(String[] args) {


        Map<String, Map<Integer, Double>> map = new HashMap();

        Map<Integer, Double> map1 = new HashMap<>();
        map1.put(50, 0.1);
        map1.put(100, 0.1);
        map1.put(150, 0.3);
        map1.put(200, 0.5);

        Map<Integer, Double> map2 = new HashMap<>();
        map2.put(50, 0.2);
        map2.put(100, 0.5);
        map2.put(150, 0.2);
        map2.put(200, 0.1);


        Map<Integer, Double> map3 = new HashMap<>();
        map3.put(50, 0.2);
        map3.put(100, 0.5);
        map3.put(150, 0.2);
        map3.put(200, 0.1);

        Map<Integer, Double> map4 = new HashMap<>();
        map4.put(50, 0.2);
        map4.put(100, 0.5);
        map4.put(150, 0.2);
        map4.put(200, 0.1);

        Map<Integer, Double> map5 = new HashMap<>();
        map5.put(50, 0.2);
        map5.put(100, 0.5);
        map5.put(150, 0.2);
        map5.put(200, 0.1);

        Map<Integer, Double> map6 = new HashMap<>();
        map6.put(50, 0.2);
        map6.put(100, 0.5);
        map6.put(150, 0.2);
        map6.put(200, 0.1);

        Map<Integer, Double> map7 = new HashMap<>();
        map7.put(50, 0.2);
        map7.put(100, 0.5);
        map7.put(150, 0.2);
        map7.put(200, 0.1);

        Map<Integer, Double> map8 = new HashMap<>();
        map8.put(50, 0.2);
        map8.put(100, 0.5);
        map8.put(150, 0.2);
        map8.put(200, 0.1);


        map.put("small_low", map1);
        map.put("small_medium", map2);
        map.put("small_high", map3);
        map.put("small_default", map4);
        map.put("big_low", map5);
        map.put("big_medium", map6);
        map.put("big_high", map7);
        map.put("big_default", map8);

        String str = JSON.toJSONString(map);

        String model = "{\"small_low\":{50:0.5,100:0.4,150:0.05,200:0.05},\n" +
                "\n" +
                "\"small_medium\":{50:0.2,100:0.5,150:0.2,200:0.1},\n" +
                "\n" +
                "\"small_high\":{50:0.1,100:0.1,150:0.3,200:0.5},\n" +
                "\n" +
                "\"small_null\":{50:0.3,100:0.5,150:0.1,200:0.1},\n" +
                "\n" +
                "\"big_low\":{200:0.6,300:0.3,350:0.05,400:0.05},\n" +
                "\n" +
                "\"big_medium\":{200:0.2,300:0.5,350:0.2,400:0.1},\n" +
                "\n" +
                "\"big_high\":{200:0.1,300:0.1,350:0.3,400:0.5},\n" +
                "\n" +
                "\"big_null\":{200:0.3,300:0.5,350:0.15,400:0.05}}";

        System.out.println(model.getBytes().length);
        System.out.println("ok".getBytes().length);


        Map<String, Map<Integer, Double>> result = JSONObject.parseObject(str, new TypeReference<Map<String, Map<Integer, Double>>>() {});

        System.out.println(result);


    }
}
